class Person {
  public name: string;
  private age: number;
  protected sex: string;
  public sayHello() {
    console.log(this.name + " say hello");
  }
}
const person = new Person();
person.name = "jspang.com";
console.log(person.name);
console.log(person.sayHello());
// person.age = 20;  报错 只能在类内访问
// person.sex = "male"; 报错 只能在类和继承的类内访问

class Teacher extends Person {
  public sayBye() {
    console.log(this.name); //访问 public 属性
    //console.log(this.age); 报错
    console.log(this.sex); //访问 protected 属性
  }
}
